1. Field of the Invention
The present invention relates to a method and related apparatus for data migration of a disk array, and more particularly, to a method and related apparatus capable of reducing a number of writing controls to improve the efficiency of data migration/transfer of a disk array.
2. Description of the Prior Art
A computer system allows a user to manage, process and access a large quantity of information, data and media, and thereby is an important element of modern society. The information industry develops improvements to computer systems, such that the systems are capable of accessing more data at higher speed and with higher precision.
With the falling costs and increasing capacities of hard disks, many computer systems include a disk array by using different data configurations. For instance, a redundant array of inexpensive disks (RAID) system has different data configurations, such as RAID 0 to RAID 5. For the data configurations RAID 0 and RAID 2 to RAID 5, when performing a writing control to write data into the disk array, the data is striped into a plurality of sub-data (i.e. data stripes) in a stripe manner, and then each sub-data is respectively written to the disks of the disk array. Similarly, while reading data from the disk array, each sub-data is simultaneously read from the different disks of the disk array and combined to obtain the original data again. Whether reading or writing data, disks of the disk array are parallel-working at the same time and thereby provide a higher efficiency of data access.
However, the cost of disk arrays is pretty high; therefore, most computer systems only have one hard disk when leaving the factory. If the user has different requirements, other disks can be added in the computer system so as to improve the efficiency of the disk array. In other situations, there may already have a disk array in the user's computer system. But the user wants to add more disks into the disk array, such that the original small disk array (with a small number of disks) is upgraded to a disk array with a large number of disks. In either situation, if the disk array is upgraded, the user might perform data migration to read data from the original disk array and then re-store data to the upgraded disk array according to the new data configuration.
Please refer to FIG. 1, which is a flowchart of data migration according to the prior art. Suppose that there is only a hard disk A in a computer system. However, the user adds a hard disk B in the computer system to integrate the hard disk A and the hard disk B into a disk array, such as a RAID 0 disk array. Therefore, the user performs data migration to read data from the hard disk A (regarded as a source disk) and then store the read data into disks of the disk array according to the data configuration of the disk array. As known in the art, when the computer system accesses the hard disks, the hard disk controller of the chipset or the disk array controller sends a reading or writing command conforming to advanced technology attachment (ATA) to each disk to perform a reading or writing control. These reading or writing commands will inform the hard disk how many bytes of data are to be accessed and where the data are located in the memory space. Generally, while performing a reading or writing command, the data size of the required read or written data has a maximum. For instance, the maximum data size for a reading command in an ATA specification is 128K bytes, i.e. reading 128K bytes from an assigned region. In the same way, the maximum of data size for a writing command in the ATA specification is also 128K bytes, i.e. writing 128K bytes into an assigned region. In other words, the maximum of a single reading/writing command is 128K bytes. FIG. 1 is a procedure of sending reading or writing commands to each disk when performing data transfer according to the prior art.
As shown in FIG. 1, when performing data transfer, the prior art computer system sends a reading command 102 to disk A, such that 128K-byte data is read from disk A. As mentioned above, the disk array integrated by the hard disk A and B is a disk array allowing parallel access. Therefore, data is stripes into two parts and then respectively stored in the hard disks A and B. According to the command 102, the read data with data size of 128K bytes is striped into two parts with data size of 64K bytes. At the same time, commands 104A and 104B are respectively sent to the hard disks A and B to write or store these two parts into the hard disks A and B.
After completing commands 104A and 104B, the command 106 is sent to the hard disk A to read another 128K-byte data from the hard disk A. Then the two 64K-byte parts are respectively written into the hard disks A and B based on the commands 108A and 108B. The control command sequence “reading 128K, writing 64K-64K, reading 128K, writing 64K-64K” is repeated so that the prior art can sequentially transfer the remaining data to complete data migration.
However, there are some drawbacks in the prior art. As mentioned above, the maximum data size accessible by each reading or writing command is 128K bytes. In the prior art, commands 102 and 106 access 128K-byte data from the hard disk A to instruct the hard disk A to read the maximum of data size in a single control command. However, after getting 128K-bytes of data, according to the configuration of the disk array, the prior art uses two 64K-byte writing commands to respectively write two 64K-byte parts into the hard disks A and B. In fact, the maximum data size for a single writing command is 128K bytes. That is, the prior art cannot make full use of the maximum data size for a single writing command.
Generally, when a file (such as 1024K-byte file) is written into the hard disk, if each writing command could write as much data as possible, the number of writing controls can be reduced to completely write the file into the hard disk. On the contrary, if each writing command writes less data, the number of writing controls is increased to completely write the same file into the hard disk. When the computer system sends commands to the hard disk, it requires a large amount of system resources. As for the data migration shown in FIG. 1, the number of writing controls is large because each writing command writes data less than 128K bytes and thereby requires more of the system's resources. This leads to poor efficiency of data migration.